package com.irdstudio.cdp.pboc.service.common;

import com.irdstudio.basic.framework.core.util.DateTool;

import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
import java.util.function.IntPredicate;

/**
 * 一代征信工具类: <br>
 * <p>
 * 0.1:caoxin:2019/5/9 19:57: TODO: <br>
 *
 * @author caoxin
 * @version 0.1
 * @date 2019/5/9 19:57
 * @since 2019/5/9 19:57
 */
public class RuleUtils  {
    // 01贷后管理，02贷款审批，03信用卡审批，08担保资格审查
    public static final String QUERY_REASON_01 = "01";
    public static final String QUERY_REASON_02 = "02";
    public static final String QUERY_REASON_03 = "03";
    public static final String QUERY_REASON_08 = "08";

   //0信用报告查询，1身份信息核查，2信用报告查询(含数字解读)
    public static final String QUERY_TYPE_0 = "0";
    public static final String QUERY_TYPE_1 = "1";
    public static final String QUERY_TYPE_2 = "2";

    // 贷记卡:CRDT 准贷记卡:NECT
    public static final String CARTTYEP_CRDT = "CRDT";
    public static final String CARTTYEP_NECT = "NECT";

    /**
     * 获取前一个月日期: <br>
     *
     * 0.1:caoxin:2019/5/10 17:45: TODO: <br>
     * @author caoxin
     * @return
     * @since 2019/5/10 17:45
     * @date 2019/5/10 17:45
     * @version 0.1
     */

    public static String getFrontMonthDate(String dateStr){
        String dateTimeStr = dateStr.replace(".", "-");
        Date dateFromLongStr = DateTool.getDateFromLongStr(dateTimeStr);
        Calendar instance = Calendar.getInstance();
        instance.setTime(dateFromLongStr);
        instance.add(Calendar.MONTH,-1);
        String dateTemp = DateTool.getDateTimeStr(instance.getTime());
        return dateTemp.replace("-",".");
    }
    /**
     * 截取年和月: <br>
     *
     * 0.1:caoxin:2019/5/10 17:46: TODO: <br>
     * @author caoxin
     * @return
     * @since 2019/5/10 17:46
     * @date 2019/5/10 17:46
     * @version 0.1
     */

    public static String subStringYearAndMonth(String dateStr){
        return dateStr.substring(0,7);
    }
}
